home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PORTABLE.ZIP / RESETTY.C < prev    next >
Text File  |  1992-11-21  |  2KB  |  71 lines

  1. #include <string.h>
  2. #define        CURSES_LIBRARY  1
  3. #include <curses.h>
  4. #undef resetty
  5.  
  6. #ifndef NDEBUG
  7. char *rcsid_resetty = "$Header: c:/curses/portable/RCS/resetty.c%v 2.0 1992/11/15 03:29:10 MH Rel $";
  8. #endif
  9.  
  10.  
  11.  
  12.  
  13. /*man-start*********************************************************************
  14.  
  15.   resetty()    - save/restore terminal modes
  16.  
  17.   X/Open Description:
  18.        These routines save and restore the state of the terminal modes.
  19.        The savetty() function saves the current state in a buffer and
  20.        resetty() restores the state to what it was at the last call to
  21.        savetty().
  22.  
  23.   PDCurses Description:
  24.        FYI: It is very unclear whether this is a duplication of the
  25.        reset_prog_mode() and reset_shell_mode() functions or whether
  26.        this is a backing store type of operation.  At this time, they
  27.        are implemented similar to the reset_*_mode() routines.
  28.  
  29.   X/Open Return Value:
  30.        The resetty() function returns OK upon success otherwise ERR is
  31.        returned.
  32.  
  33.   Portability:
  34.        PDCurses        int resetty( void );
  35.        X/Open Dec '88  int resetty( void );
  36.        SysV Curses     int resetty( void );
  37.        BSD Curses      int resetty( void );
  38.  
  39. **man-end**********************************************************************/
  40.  
  41. int    resetty(void)
  42. {
  43.        if      (c_save_tty.been_set == TRUE)
  44.        {
  45. #if    defined(DOS) || defined(OS2)
  46. #  if  SMALL || MEDIUM
  47.        movedata( FP_SEG(&c_save_tty.saved), FP_OFF(&c_save_tty.saved),
  48.                  FP_SEG(&_cursvar), FP_OFF(&_cursvar),
  49.                  sizeof(SCREEN) );
  50. #  else
  51.                memcpy(&_cursvar, &c_save_tty.saved, sizeof(SCREEN));
  52. #  endif
  53. #endif
  54.  
  55.                mvcur(0, 0, c_save_tty.saved.cursrow, c_save_tty.saved.curscol);
  56.                if (PDC_get_ctrl_break() != c_save_tty.saved.orgcbr)
  57.                        PDC_set_ctrl_break(c_save_tty.saved.orgcbr);
  58.                if (c_save_tty.saved.raw_out)
  59.                        raw();
  60.                if (c_save_tty.saved.visible_cursor)
  61.                        curson();
  62.                _cursvar.font = PDC_get_font();
  63.                PDC_set_font(c_save_tty.saved.font);
  64.                if (!PDC_scrn_modes_equal (PDC_get_scrn_mode(), c_save_tty.saved.scrnmode))
  65.                        PDC_set_scrn_mode(c_save_tty.saved.scrnmode);
  66.  
  67.                PDC_set_rows(c_save_tty.saved.lines);
  68.        }
  69.        return( c_save_tty.been_set ? OK : ERR );
  70. }
  71.